package com.aaron.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * @author aaron
 *
 */
public class ProjectPropertiesPanel extends Composite {
	private String project_name;
	private String auth;
	
	private VerticalPanel panel;
	private HTML stats;
	public ProjectPropertiesPanel(String project_name, String auth){
		this.project_name=project_name;
		this.auth=auth;
		panel=new VerticalPanel();
		panel.add(new Label("Project Properties"));
		stats=new HTML("Loading...");
		panel.add(stats);
		initWidget(panel);
		update();
	}
	private void update(){
		ProjectServiceAsync project_service=ProjectService.Util.getInstance();
		project_service.getProjectStats(project_name, auth, new AsyncCallback(){
			public void onSuccess(Object result){
				String stats_string=(String)result;
				stats.setHTML(stats_string);
			}
			public void onFailure(Throwable caught){
				stats.setHTML("Unable to fetch stats");
			}
		});
	}
}
